import Vue from 'vue'
import VueRouter from 'vue-router'

import Login from '@/views/loginView.vue'
import Layout from '@/views/layout/IndexView.vue'
import Home from '@/views/home/HomeView.vue'
Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history', // 设置为历史模式
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
    {
      path: '/layout',
      component: Layout,
      // redirect: '/layout/home',
      children: [
        { path: '/layout/home', component: Home }
      ]
    }
  ]
})
// 路由前卫
// router.beforeEach((to, from, next) => {
//   // console.log(to)
//   if (to.path === '/login') {
//     next() // 放行
//   } else {
//     next('/login')
//   }
// })

export default router
